# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=tar
pkgver=1.35
pkgrel=2
pkgdesc="Utility used to store, backup, and transport files"
url="https://www.gnu.org/software/tar/"
arch="all"
license="GPL-3.0-or-later"
makedepends="acl-dev"
subpackages="$pkgname-doc"
source="https://ftp.gnu.org/gnu/tar/tar-$pkgver.tar.xz
	ignore-apk-tools-checksums.patch
	"

# secfixes:
#   1.34-r2:
#     - CVE-2022-48303
#   1.34-r0:
#     - CVE-2021-20193
#   1.29-r1:
#     - CVE-2016-6321
#   1.31-r0:
#     - CVE-2018-20482
#   0:
#     - CVE-2021-32803
#     - CVE-2021-32804
#     - CVE-2021-37701

build() {
	if [ -z "$BOOTSTRAP" ]; then
		export CFLAGS="$CFLAGS -flto=auto"
	fi
	gl_cv_func_gettimeofday_clobber=no \
	gl_cv_func_tzset_clobber=no \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	make check || {
		cat tests/testsuite.log
		return 1
	}
}

package() {
	make DESTDIR="$pkgdir/" install

	mkdir "$pkgdir"/bin
	mv "$pkgdir"/usr/bin/tar "$pkgdir"/bin/
	ln -s /bin/tar "$pkgdir"/usr/bin/tar
}

sha512sums="
8b84ed661e6c878fa33eb5c1808d20351e6f40551ac63f96014fb0d0b9c72d5d94d8865d39e36bcb184fd250f84778a3b271bbd8bd2ceb69eece0c3568577510  tar-1.35.tar.xz
e60c479c41e8f9bdfbc933857e26b3b7844fb04021a7d4a9cbd7fb44cc2acac98ea109a41dca38bff9b388eac8e17348310e42eb3c70fe5594d83ee0aca27102  ignore-apk-tools-checksums.patch
"
